<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>E3-demo</title>
		<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
		<link rel="stylesheet" href="css/all.css" />
		<style>

		</style>
	</head>

	<body class="own-gray-color">
		<nav class="mui-bar mui-bar-tab" id="bar">
			<a class="mui-tab-item mui-active" href="index.html" data-id='0'>
				<span class="mui-icon mui-icon-home-filled"></span>
				<span class="mui-tab-label">首页</span>
			</a>
			<a class="mui-tab-item shake" href="/home/tixing.html" data-id="1">
				<span class="mui-icon mui-icon-chat">
					<span class="mui-badge mui-badge-warning">3</span>
				</span>
				<span class="mui-tab-label">提醒类表</span>
			</a>
			<a class="mui-tab-item shake" href="/home/tixing.html" data-id="2">
				<span class="mui-icon mui-icon-chat">
					<span class="mui-badge mui-badge-warning"><label id="gouwuche">0</label></span>
				</span>
				<span class="mui-tab-label">购物车</span>
			</a>
			<a class="mui-tab-item" href="/home/self.html" data-id='3'>
				<span class="mui-icon mui-icon-qq">
			</span>
				<span class="mui-tab-label">关于我</span>
			</a>
		</nav>
		<div class="mui-content mui-loader">正在加载...</div>
	</body>
	<script type="text/javascript" src="js/mui.min.js"></script>
	<script>
		var index = 0;
		var subpages = ['barItem/home.html', 'barItem/cart.html', 'barItem/category.html', 'barItem/mine.html'];
		mui.preload({
			url: 'barItem/home.html',
			id: 'barItem/home.html'
		})
		mui.plusReady(function() {
			var style = {
				top: '0px',
				bottom: '51px'
			};
			var tabconfig = {};
			var self = plus.webview.currentWebview();
			tabconfig[0] = plus.webview.create(subpages[0], subpages[0], style);
			self.append(tabconfig[0]);
			//创建子页
			setTimeout(function() {
				var length = subpages.length;
				for (var i = 1; i < length; i++) {
					tabconfig[i] = plus.webview.create(subpages[i], subpages[i], style);
					tabconfig[i].hide();
				}
				mui("#bar").on("tap", "a", function(e) {
					var noeNum = this.dataset.id;
					if (noeNum == index) return;
					else {
						tabconfig[index].hide("fade-out", 100);
						tabconfig[noeNum].show("fade-in", 400);
						index = noeNum;
					}
				})
			}, 300)
		});
		window.addEventListener("updateProduct", function(e) {
			var product = document.getElementById("gouwuche");
			var productnum = product.innerText;
			product.innerText = parseInt(productnum) + 1;
		})
		var first=null;
			mui.back = function() {
				//首次按键，提示‘再按一次退出应用’
				backall();
			};
	   window.addEventListener("backall",function()
	   {
	   	   backall();
	   })
	   function backall()
	   {
	   	if (!first) {
					first = new Date().getTime();
					mui.toast('再按一次退出应用');
					setTimeout(function() {
						first = null;
					}, 1000);
				} else {
					if (new Date().getTime() - first < 1000) {
						localStorage.removeItem("user");
						plus.runtime.quit();
					}
				}
	   }
	</script>

</html>